﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Crm.Sdk.Query;

namespace XrmLibrary.MsCrm4Adapter.Extensions
{
    public static class ColumnSetExtensions
    {
        public static Microsoft.Crm.Sdk.Query.ColumnSetBase ToColumnSet4(this Microsoft.Xrm.Sdk.Query.ColumnSet columnSet2011)
        {
            Microsoft.Crm.Sdk.Query.ColumnSetBase columnSet4 = null;
            if(columnSet2011.AllColumns)
            {
                columnSet4 = new Microsoft.Crm.Sdk.Query.AllColumns();
            }
            else
            {
                foreach (var col in columnSet2011.Columns)
                {
                    columnSet4 = new ColumnSet();
                    columnSet4.AddColumn(col);
                }
            }
            return columnSet4;
        }
    }
}
